﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Forum.Master" AutoEventWireup="true" CodeBehind="User.aspx.cs" Inherits="Client.WebForm3" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<meta name="keywords" content="travel and tour, free website template, CSS, HTML" />
<meta name="description" content="Travel and Tour - free website template provided by templatemo.com" />
<link href="templatemo_style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="Scripts/json2.js"></script>
<script type="text/javascript" src="Scripts/json_parse.js"></script>
<script type="text/javascript" src="Scripts/json_parse_state.js"></script>
<script type="text/javascript" src="Scripts/cycle.js"></script>
<script type="text/javascript" src="Scripts/1.js"></script> 
<script src="http://code.jquery.com/jquery-latest.js"></script>
    <script src="Scripts/jquery-1.8.2.js"></script>
    <script src="Scripts/jquery-ui-1.9.1.custom.js"></script>
    <link rel="stylesheet" href="Styles/jquery-ui-1.9.2.custom.css" />
    <link rel="stylesheet" media="screen" href="lib/datatables/css/cleanslate.css" />
     <script type="text/javascript" src="lib/datatables/js/jquery.dataTables.js"></script> 
   


    <link rel="stylesheet" href="Styles/jquery-ui.css" />
    <script>
        $(function () {
            var URL = 'http://localhost:18796/api/values/';
            $(function GetUser() {
                jQuery.support.cors = true;
                $.ajax({
                    url: URL + '?AllUser=',
                    type: 'GET',
                    datatype: 'json',
                    success: function (data) {
                        $("#TableUser").empty();
                        for (var i = 0; i < data.length; i++) {
                            $("#TableUser").append(
                                    "<tr class='gradeX'> " +
                                    "    <td><img src='" + data[i].avatar + "' width='40px'/></td> " +
                                     "   <td>" + data[i].Name + "</td>   " +
                                    "   <td class='center'>" + data[i].stt + "</td> " +
                                     "   " +
                                   " </tr> "
                            );

                        }
                        $('#example').dataTable();
                    },
                    error: function () {
                        alert("Error rồi");
                    }
                });
            });
            var b=setInterval( function() {
                $(function GetUser() {
                    jQuery.support.cors = true;
                    $.ajax({
                        url: URL + '?AllUser=',
                        type: 'GET',
                        datatype: 'json',
                        success: function (data) {
                            $("#TableUser").empty();
                            for (var i = 0; i < data.length; i++) {
                                $("#TableUser").append(
                                    "<tr class='gradeX'> " +
                                    "    <td><img src='" + data[i].avatar + "' width='40px'/></td> " +
                                     "   <td>" + data[i].Name + "</td>   " +
                                    "   <td class='center'>" + data[i].stt + "</td> " +
                                     "   " +
                                   " </tr> "
                            );

                            }
                            $('#example').dataTable();
                        },
                        error: function () {
                            alert("Error rồi");
                        }
                    });
                });
             },90000);
            $("#Delete1")
            .button()
            .click(function () {
                jQuery.support.cors = true;
                $.ajax({
                    url: URL + '?DelUser=' + $("#DelUser").val(),
                    type: 'GET',
                    datatype: 'json',
                    success: function (data) {
                        if (data == true) {
                            alert("Xoa Thanh Cong");
                            window.location.reload();
                        }
                        else {
                            alert("Xoa That Bai");
                        }


                    },
                    error: function () {
                        alert("Error rồi");
                    }
                });

            });
            $("#Update1")
            .button()
            .click(function () {
                jQuery.support.cors = true;
                $.ajax({
                    url: URL + '?name=' + $("#UpUser1").val() + '&newpass=' + $("#UpUser2").val() + '&url=' + $("#UpUser3").val(),
                    type: 'GET',
                    datatype: 'json',
                    success: function (data) {
                        if (data == true) {
                            alert("cap nhat Thanh Cong");
                            window.location.reload();
                        }
                        else {
                            alert("cap nhat That Bai");
                        }
                    },
                    error: function () {
                        alert("Error rồi");
                    }
                });
            });
            $("#AddUser1")
            .button()
            .click(function () {
                window.location = "SignUpPage.aspx";
            });
        });
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<div>
User:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input id="DelUser" type="text" /> 
    <input id="Delete1" type="button" value="Delete" />
</div>
    <div>
User:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input id="UpUser1" type="text" /> <br />newpass:  <input id="UpUser2" type="password" /> <br />url:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input id="UpUser3" type="text" />
    <input id="Update1" type="button" value="Update" />
</div>
<div><input id="AddUser1" type="button" value="Add User" />
</div>
<br />
 <table class="display" id="example"> 
                                <thead> 
                                    <tr> 
                                        <th>Avatar</th> 
                                        <th>UserName</th> 
                                        <th>Status</th> 
                                    </tr> 
                                </thead> 
                                <tbody id="TableUser"> 
                                  
                                  
                                </tbody> 
                            </table> 

</asp:Content>
